package com;

import com.baima46.ExcelPlus;
import com.model.Coder;
import com.model.Person;
import lombok.extern.slf4j.Slf4j;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * @Description
 * @Author yuan cong
 * @Date 2020/12/4 0004
 */
@Slf4j
public class ExcelTest {
    public static void main(String[] args) {
//        simpleExcelTest();
//        extendExcelTest();
//        dymExcelTest();
        dymgExcelTest();
    }


    /**
     * 简单excel导出测试
     *  条数      列数      耗时（秒）
     *  100         2       0.891
     *  1000        2       1.04
     *  10000       2       1.234
     *  100000      2       1.909
     *  500000      2       4.422
     */
    private static void simpleExcelTest(){
        long start = System.currentTimeMillis();
        int num = 100000;

        ExcelPlus.exportExcel(new File("./简单excel导出测试.xlsx"), Person.getPerson(num), Person.class);

        long end = System.currentTimeMillis();
        log.info("简单excel导出测试，条数：{},耗时：{}秒", num, (end-start)/1000.0);
    }


    /**
     * 表头字段继承excel导出测试
     *  条数      列数      耗时（秒）
     *  100         2       0.891
     *  1000        2       1.33
     *  10000       2       1.494
     *  100000      2       2.5
     *  500000      2       4.422
     */
    private static void extendExcelTest(){
        long start = System.currentTimeMillis();
        int num = 1000;

        ExcelPlus.exportExcel(new File("./表头字段继承excel导出测试.xlsx"), Coder.getCoder(num), Coder.class);

        long end = System.currentTimeMillis();
        log.info("表头字段继承excel导出测试，条数：{},耗时：{}秒", num, (end-start)/1000.0);
    }

    /**
     * 动态列字段+继承 excel导出测试
     *  条数      列数      耗时（秒）
     *  100         2       0.891
     *  1000        2       1.874
     *  10000       2       1.494
     *  100000      2       2.5
     *  500000      2       4.422
     */
    private static void dymExcelTest(){
        long start = System.currentTimeMillis();
        int num = 10000;

        ExcelPlus.exportExcel(new File("./动态列字段+继承excel导出测试.xlsx"), Coder.getCoder2(num), Coder.class);

        long end = System.currentTimeMillis();
        log.info("动态列字段+继承excel导出测试，条数：{},耗时：{}秒", num, (end-start)/1000.0);
    }

    /**
     * 动态列字段+继承+分组 excel导出测试
     *  条数      列数      耗时（秒）
     *  100         2       0.891
     *  1000        2       1.874
     *  10000       2       1.494
     *  100000      2       2.5
     *  500000      2       4.422
     */
    private static void dymgExcelTest(){
        long start = System.currentTimeMillis();
        int num = 10000;

        ExcelPlus.exportExcel(new File("./动态列字段+继承+分组excel导出测试.xlsx"), Coder.getCoder2(num), Coder.class, "d");

        long end = System.currentTimeMillis();
        log.info("动态列字段+继承+分组excel导出测试，条数：{},耗时：{}秒", num, (end-start)/1000.0);
    }

}
